from herschelhelp_internal import git_version
print("This notebook was run with herschelhelp_internal version: \n{}".format(git_version()))
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
plt.rc('figure', figsize=(10, 6))
plt.style.use('ggplot')
import locale
locale.setlocale(locale.LC_ALL, 'en_GB')
import os
import time
import itertools
from astropy.coordinates import SkyCoord
from astropy.table import Table
from astropy import units as u
from astropy import visualization as vis
import numpy as np
from matplotlib_venn import venn2
from herschelhelp_internal.masterlist import (nb_compare_mags, nb_ccplots, nb_histograms, find_last_ml_suffix,
quick_checks)
OUT_DIR = os.environ.get('OUT_DIR', "./data")
SUFFIX = find_last_ml_suffix()
#SUFFIX = "20170710"
master_catalogue_filename = "master_catalogue_elais-n2_{}.fits".format(SUFFIX)
master_catalogue = Table.read("{}/{}".format(OUT_DIR, master_catalogue_filename))
print("Diagnostics done using: {}".format(master_catalogue_filename))
quick_checks(master_catalogue).show_in_notebook()
flag_obs = master_catalogue['flag_optnir_obs']
flag_det = master_catalogue['flag_optnir_det']
venn2(
[
np.sum(flag_obs == 1),
np.sum(flag_obs == 4),
np.sum(flag_obs == 5)
],
set_labels=('Optical', 'mid-IR'),
subset_label_formatter=lambda x: "{}%".format(int(100*x/len(flag_obs)))
)
plt.title("Wavelength domain observations");
venn2(
[
np.sum(flag_det[flag_obs == 5] == 1),
np.sum(flag_det[flag_obs == 5] == 4),
np.sum(flag_det[flag_obs == 5] == 5)
],
set_labels=('Optical', 'Mid-IR'),
subset_label_formatter=lambda x: "{}%".format(int(100*x/np.sum(flag_det != 0)))
)
plt.title("Detection of the {} sources detected\n in any wavelength domains "
"(among {} sources)".format(
locale.format('%d', np.sum(flag_det != 0), grouping=True),
locale.format('%d', len(flag_det), grouping=True)));
The master list if composed of several catalogues containing magnitudes in similar filters on different instruments. We are comparing the magnitudes in these corresponding filters.
u_bands = ["WFC u", "CFHT Megacam u"]
g_bands = ["WFC g", "CFHT Megacam g", "GPC1 g", "RCS g"]
r_bands = ["WFC r", "CFHT Megacam r", "GPC1 r", "RCS r"]
i_bands = ["WFC i", "GPC1 i", "RCS i"]
z_bands = ["WFC z", "CFHT Megacam z", "GPC1 z", "RCS z"]
y_bands = [ "GPC1 y", "RCS y"]
We compare the histograms of the total aperture magnitudes of similar bands.
for bands in [u_bands, g_bands, r_bands, i_bands, z_bands, y_bands]:
colnames = ["m_{}".format(band.replace(" ", "_").lower()) for band in bands]
nb_histograms(master_catalogue, colnames, bands)
We compare one to one each magnitude in similar bands.
for band_of_a_kind in [u_bands, g_bands, r_bands, i_bands, z_bands, y_bands]:
for band1, band2 in itertools.combinations(band_of_a_kind, 2):
basecol1, basecol2 = band1.replace(" ", "_").lower(), band2.replace(" ", "_").lower()
col1, col2 = "m_ap_{}".format(basecol1), "m_ap_{}".format(basecol2)
nb_compare_mags(master_catalogue[col1], master_catalogue[col2],
labels=("{} (aperture)".format(band1), "{} (aperture)".format(band2)))
col1, col2 = "m_{}".format(basecol1), "m_{}".format(basecol2)
nb_compare_mags(master_catalogue[col1], master_catalogue[col2],
labels=("{} (total)".format(band1), "{} (total)".format(band2)))
Cross-match the master list to SDSS magnitudes.
master_catalogue_coords = SkyCoord(master_catalogue['ra'], master_catalogue['dec'])
The catalogue is cross-matched to SDSS-DR13 withing 0.2 arcsecond.
We compare the u, g, r, i, and z magnitudes to those from SDSS using fiberMag for the aperture magnitude and petroMag for the total magnitude.
sdss = Table.read("../../dmu0/dmu0_SDSS-DR13/data/SDSS-DR13_ELAIS-N2.fits")
sdss_coords = SkyCoord(sdss['ra'] * u.deg, sdss['dec'] * u.deg)
idx, d2d, _ = sdss_coords.match_to_catalog_sky(master_catalogue_coords)
mask = (d2d < 0.2 * u.arcsec)
sdss = sdss[mask]
ml_sdss_idx = idx[mask]
for band_of_a_kind in [u_bands, g_bands, r_bands, i_bands, z_bands]:
for band in band_of_a_kind:
sdss_mag_ap = sdss["fiberMag_{}".format(band[-1])]
master_cat_mag_ap = master_catalogue["m_ap_{}".format(band.replace(" ", "_").lower())][ml_sdss_idx]
nb_compare_mags(sdss_mag_ap, master_cat_mag_ap,
labels=("SDSS {} (fiberMag)".format(band[-1]), "{} (aperture)".format(band)))
sdss_mag_tot = sdss["petroMag_{}".format(band[-1])]
master_cat_mag_tot = master_catalogue["m_ap_{}".format(band.replace(" ", "_").lower())][ml_sdss_idx]
nb_compare_mags(sdss_mag_ap, master_cat_mag_ap,
labels=("SDSS {} (petroMag)".format(band[-1]), "{} (total)".format(band)))
From here, we are only comparing sources with a signal to noise ratio above 3, i.e. roughly we a magnitude error below 0.3.
To make it easier, we are setting to NaN in the catalogue the magnitudes associated with an error above 0.3 so we can't use these magnitudes after the next cell.
for error_column in [_ for _ in master_catalogue.colnames if _.startswith('merr_')]:
column = error_column.replace("merr", "m")
keep_mask = np.isfinite(master_catalogue[error_column])
keep_mask[keep_mask] &= master_catalogue[keep_mask][error_column] <= 0.3
master_catalogue[column][~keep_mask] = np.nan
nb_ccplots(
master_catalogue['m_cfht_megacam_r'],
master_catalogue['m_ap_cfht_megacam_r'] - master_catalogue['m_cfht_megacam_r'],
"r total magnitude (CFHT)", "r aperture mag - total mag (CFHT)",
master_catalogue["stellarity"],
invert_x=True
)
nb_ccplots(
master_catalogue['m_wfc_i'] - master_catalogue['m_swire_irac1'],
master_catalogue['m_wfc_g'] - master_catalogue['m_wfc_i'],
"WFC i - IRAC1", "g - i (WFC)",
master_catalogue["stellarity"]
)
nb_ccplots(
master_catalogue['m_cfht_megacam_u'] - master_catalogue['m_cfht_megacam_g'],
master_catalogue['m_cfht_megacam_g'] - master_catalogue['m_cfht_megacam_r'],
"u - g (CFHT)", "g - r (CFHT)",
master_catalogue["stellarity"]
)
nb_ccplots(
master_catalogue['m_irac3'] - master_catalogue['m_irac4'],
master_catalogue['m_swire_irac1'] - master_catalogue['m_swire_irac2'],
"IRAC3 - IRAC4", "IRAC1 - IRAC2",
master_catalogue["stellarity"]
)